<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增班级信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-classInfo-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">班级名称：</label>
                <div class="col-sm-8">
                    <input id="name" name="name" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">班级描述：</label>
                <div class="col-sm-8">
                    <textarea name="introduce" class="form-control"></textarea>
                </div>
            </div>
           
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">班级辅导员老师：</label>
                 <!--督导员编号   -->            
                 <input name="teacherName" class="form-control" type="hidden" id="teacherName" > 
                <div class="col-sm-8">
                <select class="form-control m-b" name="teacherId" id="teacherId">                  
                   <option th:each="teacher : ${teachers}" th:text="${teacher.name}" th:value="${teacher.id}"></option>
                </select>                   
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "course/classInfo"        
        $("#form-classInfo-add").validate({
        	onkeyup: false,
        	rules:{
        		name:{        			
        			maxlength: 2000,
        			remote: {
                        url: prefix + "/checkClassNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                        	"name": function() {
                                return $.common.trim($("#name").val());
                            }
                        },
                        dataFilter: function(data, type) {
                        	return $.validate.unique(data);
                        }
                    }
        		}
        	},
        	messages: {
                "name": {
                    remote: "班级名称已经存在"
                }
            },
            focusCleanup: true
        });
                    

        function submitHandler() {
            if ($.validate.form()) {
            	//把教师的名称也提交到后台
            	$("#teacherName").val($("#teacherId").find("option:selected").text());
                $.operate.save(prefix + "/add", $('#form-classInfo-add').serialize());
            }
        }
    </script>
</body>
</html>